#ifndef __CALEVENT_HH
#define __CALEVENT_HH

#include <iostream>
#include <vector>
#include <iomanip>

#include "Time.hh"
#include "Barrel.hh"
#include "Annular.hh"
#include "Mux.hh"
#include "Germanium.hh"
#include "BuiltEvent.hh"
#include "Settings.hh"
#include "Calibration.hh"

using namespace std;

class CalEvent : public TObject {
public:
  CalEvent();
  CalEvent(Calibration*, Settings*);
  ~CalEvent();
  
  void Clear();
  //set
  void SetTime(long long, long long, long long);
  void SetFBarrel(int, vector<vector<unsigned short> > &, vector<long long>);
  void SetBBarrel(int, vector<vector<unsigned short> > &, vector<long long>);
  //void SetFCD(int, vector<vector<unsigned short> > &, vector<long long>, Mux* mux);
  void SetBCD(int, vector<vector<unsigned short> > &, vector<long long>, Mux* mux);
  void SetCluster(int cluster, vector<DgfData>);
  //get
  vector<Barrel>* GetFBarrel(){
    return &fFBarrel;
  };  
  vector<Barrel>* GetBBarrel(){
    return &fBBarrel;
  };
  vector<Annular>* GetFCD(){
    return &fFCD;
  };
  vector<Annular>* GetBCD(){
    return &fBCD;
  };
  vector<Germanium>* GetCluster(){
    return &fCluster;
  }
  long long GetEbisTime(){
    return fEbisTime;
  };
  long long GetT1Time(){
    return fT1Time;
  };
  long long GetSuperCycleTime(){
    return fSuperCycleTime;
  };
  

  long long SizeOf(){
    long long result = 0;
    for(int i = 0; i < fFBarrel.size(); i++)
      result += fFBarrel[i].SizeOf();
    for(int i = 0; i < fBBarrel.size(); i++)
      result += fBBarrel[i].SizeOf();
    for(int i = 0; i < fFCD.size(); i++)
      result += fFCD[i].SizeOf();
    for(int i = 0; i < fBCD.size(); i++)
      result += fBCD[i].SizeOf();
    for(int i = 0; i < fCluster.size(); i++)
      result += fCluster[i].SizeOf();

    return result;
  };
  bool HasData(){
    if(fFBarrel.size() > 0)
      return true;
    if(fBBarrel.size() > 0)
      return true;
    if(fFCD.size() > 0)
      return true;
    if(fBCD.size() > 0)
      return true;
    if(fCluster.size() > 0)
      return true;
    
    return false;
  };

protected:
  Calibration* fCal;
  Settings* fSettings;
  vector<Barrel> fFBarrel;
  vector<Barrel> fBBarrel;
  vector<Annular> fFCD;
  vector<Annular> fBCD;
  vector<Germanium> fCluster;

  long long fEbisTime;
  long long fT1Time;
  long long fSuperCycleTime;

  ClassDef(CalEvent, 1);
};

#endif
